<template>
  <div>
    <div class="top">
      <van-icon @click="goback" class="zuo" name="arrow-left" />
      注册用户
    </div>
    <van-cell-group>
      <van-field v-model="password" label="密码" placeholder="请输入密码" />
    </van-cell-group>
    <van-button class="go" @click="goInccc" :disabled="flag">注册</van-button>
  </div>
</template>
  
  <script>
import { Toast } from "vant";
import { goReg } from "@/api/login";
export default {
  data() {
    return {
      tel: "",
      password: "",
    };
  },
  computed: {
    flag() {
      // 密码强度校验，最少6位，包括至少1个大写字母，1个小写字母，1个数字
      if (
        /^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])\S*$/.test(
          this.password
        )
      ) {
        return false;
      } else {
        return true;
      }
    },
  },
  created() {
    console.log(this.$route.query.tel);
    this.tel = this.$route.query.tel;
  },
  methods: {
    goback() {
      this.$router.back();
    },
    goInccc() {
      goReg({
        tel: this.tel,
        password: this.password,
      }).then((res) => {
        let data = res.data;
        console.log(data);
        if (data.code == 200) {
          Toast("注册成功");
          this.$router.push("/Login");
        }
      });
    },
  },
};
</script>
  
  <style scoped>
.top {
  width: 100%;
  height: 3.125rem;
  font-size: 1.25rem;
  text-align: center;
  line-height: 3.125rem;
  /* border-bottom: 0.0625rem solid black; */
  position: relative;
  background-color: red;
}
.go {
  background-color: rgb(255, 166, 2);
  width: 18.75rem;
  height: 2.5rem;
  border-radius: 0.625rem;
  border: none;
  position: absolute;
  left: 2.5rem;
  top: 12.5rem;
}
.zuo {
  position: absolute;
  left: 0.625rem;
  font-size: 1.25rem;
  top: 0.9375rem;
}
</style>